

#ifndef _TSPEERCONFIG_H_
#define _TSPEERCONFIG_H_

#ifdef __Win32__
#pragma warning(disable: 4786)
#endif

#include "OSThread.h"

#include <vector>
#include <string>
#include "OSHeaders.h"
#include "XMLNode.h"
#include "OSMutex.h"
#include "Globle.h"

typedef struct _iTSPeerConfig
{
	Bool	isNeedTS;
	//trackserver use
	UInt32	iTrackServerIP;
	UInt32	iTrackServerPort;
	UInt32  iUpdate2TSrvTimer;
	UInt32	nNumOfQueryPeers;
	UInt32	nQueryBCTimer;

	//number
	UInt32	nSameLayerFriends;
	UInt32	nUpLayerFriends;
	UInt32	nDownLayerFriends;
	UInt32	nNeighbors;

	//internal use
	UInt32  nCheckPeerTimer;
	//log server
	UInt32	nLogServerIP;
	UInt32	nLogServerPort;
	UInt32	nLogServerInterval;
}TSPeerConfig;

extern TSPeerConfig glbConfig;

class XMLDoc;
//This class only can be used by CXMLConfigMng
class CMemberConfig
{	
public:
	CMemberConfig();
	~CMemberConfig();

	Bool LoadXmlSource(const char *szBuff);
	
	Bool GetContent(const string& strPos, string& outVal);
	Bool GetContent(const string& strPos, UInt16& outVal);
	Bool GetContent(const string& strPos, UInt32& outVal);
	Bool GetContent(const string& strPos, UInt64& outVal);
	
	Bool GetProperty(const string& strPos, string& outVal);
	Bool GetProperty(const string& strPos, UInt32& outVal);
	Bool GetProperty(const string& strPos, vector<SIPandPort>&outVec);
	Bool GetProperty(const string& strPos, SIPandPort &outIpPort);

private:
	Bool GetItemValue(XMLNode* pNode, const string& strKey, UInt32 *pdwValue);
	Bool GetItemValue(XMLNode* pNode, const string& strKey, char *pcValue);
	
	void SeperateString(const string& inStr, vector<string>& outVec, const string Delimiter="/");

private:
	XMLDoc *m_pDoc;
};


#endif


